package com.dcivision.dms.core;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

import com.dcivision.dms.DmsOperationConstant;
import com.dcivision.dms.bean.DmsDocument;
import com.dcivision.dms.web.ListDmsDocumentForm;
import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.SessionContainer;

public class SharingManager {

  public static final String REVISION = "$Revision: 1.6 $";


  private SessionContainer sessionContainer = null;
  private Connection conn = null;

  public SharingManager(SessionContainer sessionContainer, Connection conn) {
    this.sessionContainer = sessionContainer;
    this.conn = conn;
  }

  /**
   *  Release - To release the variable in instance of SharingManager
   */
  public void release() {
    this.sessionContainer = null;
    this.conn = null;
  }

  public List getUserAllAccessibleRootFolderWithPersonalRoot(ListDmsDocumentForm searchForm) throws ApplicationException {
    DocumentRetrievalManager docRetrevalManager = new DocumentRetrievalManager(sessionContainer, conn);
    List resultList = new ArrayList();
    //Personal root
    DmsDocument personalRoot = docRetrevalManager.getDocumentByNameParentIDCreatorID(DmsOperationConstant.DMS_PERSONAL_ROOT, new Integer(0), sessionContainer.getUserRecordID());
    resultList.add(personalRoot);
    /*
             //Public roots
             List publicList = this.getUserAllAccessibleRootFolder();
             resultList.add(publicList);
     */
    docRetrevalManager.release();
    return resultList;
  }

}